package monster.flight.admin.action.xtgl.user;



import monster.comm.action.BaseJsonAction;
import monster.comm.exception.InvalidParameterException;
import monster.comm.exception.UniqueNeedException;
import monster.comm.log.ILog;
import monster.comm.log.LogService;
import monster.comm.util.ReturnConstant;
import monster.flight.admin.manager.service.xtgl.UsersService;
import monster.flight.admin.vo.xtgl.Xt_usersVO;
import monster.flight.comm.entity.vo.Xt_users;

/**
 * 
 * 创建信息
 * ============= 类名: monster.flight.admin.action.xtgl.UserAction
 * 类作用描述: * 后台系统管理后台管理人员增删改查 创建人：
 * wanghong 创建时间： 2013-1-18 上午11:26:10 
 * 修改信息1=============
 * 修改类型: //1.修改bug 2.业务变化修改 修改描述: 修改人： 修改时间：
 */
public class UserCheckAction extends BaseJsonAction {
	ILog log = LogService.getLog(UserCheckAction.class);
	private Xt_usersVO xt_usersVO;
	private String type;//判断验证类型
	private UsersService usersService;

	public String checkUser(){
		if("1".equals(type)){
			return checkLoginName();
		}else{
			return checkForm();
		}
	}
	/**
	 * @Description: 检查帐号是否可用
	 * @return String
	 */
	private String checkLoginName() {
		String isLogin = isLogin();
		if("1".equals(isLogin)){
			try {
				boolean isValid = usersService.vild_LoginNameOnly(xt_usersVO.getOld_login_name(), xt_usersVO.getLogin_name());
				returnVO.returnCode = ReturnConstant.IS_DEAL_OK;
				returnVO.validationReturn="[\"xt_usersVO\\\\.login_name\","+isValid+"]";
			}  catch (Exception e) {
				returnVO.returnCode = ReturnConstant.IS_ERR;
				returnVO.validationReturn="[\"xt_usersVO\\\\.login_name\",false]";
				returnVO.returnDesc = e.getMessage();
				log.error(e.getMessage(),e);
			}
		}else{
			returnVO.returnCode = ReturnConstant.IS_NOT_LOGIN;
			returnVO.validationReturn="[\"xt_usersVO\\\\.login_name\",false]";
		}		
		return SUCCESS;
	}
	/**
	 * @Description: 检查form
	 * @return String
	 */
	private String checkForm() {
		String isLogin = isLogin();
		if("1".equals(isLogin)){
			try {
				boolean isValid = usersService.vild_LoginNameOnly(xt_usersVO.getOld_login_name(), xt_usersVO.getLogin_name());
				returnVO.returnCode = ReturnConstant.IS_DEAL_OK;
				returnVO.validationReturn="[[\"xt_usersVO\\\\.login_name\","+isValid+",\"checkLoginName\"]]";
			}  catch (Exception e) {
				returnVO.returnCode = ReturnConstant.IS_ERR;
				returnVO.validationReturn="[[\"xt_usersVO\\\\.login_name\",false,\"checkLoginName\"]]";
				returnVO.returnDesc = e.getMessage();
				log.error(e.getMessage(),e);
			}
		}else{
			returnVO.returnCode = ReturnConstant.IS_NOT_LOGIN;
			returnVO.validationReturn="[[\"xt_usersVO\\\\.login_name\",false,\"checkLoginName\"]]";
		}
		return SUCCESS;
	}	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}

	
	public Xt_usersVO getXt_usersVO() {
		return xt_usersVO;
	}
	public void setXt_usersVO(Xt_usersVO xt_usersVO) {
		this.xt_usersVO = xt_usersVO;
	}
	public void setUsersService(UsersService usersService) {
		this.usersService = usersService;
	}
	

}
